/**
 * Description:
 * Class Name:ManualSeason
 * Date:2022/2/12 14:18
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第6章_面向对象_下._6_9_枚举类._6_9_1_手动实现枚举类;

public class ManualSeason {
    // 把Season类定义成不可变的，将其成员变量也定义成final的
    private final String name;
    private final String desc;
    public static final ManualSeason SPRING
            = new ManualSeason("春天" , "趁春踏青");
    public static final ManualSeason SUMMER
            = new ManualSeason("夏天" , "夏日炎炎");
    public static final ManualSeason FALL
            = new ManualSeason("秋天" , "秋高气爽");
    public static final ManualSeason WINTER
            = new ManualSeason("冬天" , "围炉赏雪");
    public static ManualSeason getManualSeason(int seasonNum)
    {
        switch(seasonNum)
        {
            case 1 :
                return SPRING;
            case 2 :
                return SUMMER;
            case 3 :
                return FALL;
            case 4 :
                return WINTER;
            default :
                return null;
        }
    }
    // 将构造器定义成private访问权限
    private ManualSeason(String name , String desc)
    {
        this.name = name;
        this.desc = desc;
    }
    // 只为name和desc提供getter方法
    public String getName()
    {
        return this.name;
    }
    public String getDesc()
    {
        return this.desc;
    }

    public static void main(String[] args) {
        var s = ManualSeason.getManualSeason(1);
        System.out.println(s.getName());
        System.out.println(s.getDesc());
    }
}
